# This file is part of ModularBot.
# Copyright (C) 2005 Pierre Ducroquet (pierre.linux59@wanadoo.fr)

# ModularBot is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# ModularBot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with ModularBot; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA


import base_logic, time

def get_hour ():
	liste = time.localtime()
	msg = "%2d:%2d" % (liste[3], liste[4])
	return msg.replace(" ", "0")

class logLogic(base_logic.Base):
	def __init__(self, core):
		base_logic.Base.__init__(self, core)
	
	def globalCall (self, ctxte):
		print "%s <+%s> %s" % (get_hour(), ctxte.user, ctxte.message)
	def kickevent (self, user, channel, kicker, reason):
		print "%s -!- %s was kicker from %s by %s [%s]" % (get_hour(), user, channel, kicker, reason)
	def joinevent (self, user, channel):
		print "%s -!- %s [~%s@nowhere] has joined %s" % (get_hour(), user, channel)
	def leftevent (self, user, channel):
		print "%s -!- %s [~%s@nowhere] has quit [I don't know]" % (get_hour(), user, channel)
	def renameevent (self, oldname, newname):
		self.bot.say(channel, "%s renamed to %s " % (oldname, newname))
	def modeevent (self, user, channel, set, modes, args):
		def set_str (status):
			if status: return "+"
			return "-"
		try:
			print "%s -!- mode/%s [%s%s %s] by %s" % (get_hour(), channel, set_str(set), modes, str(args[0]), user)
		except IndexError:
			print "%s -!- mode/%s [%s%s] by %s" % (get_hour(), channel, set_str(set), modes, user)
